<!DOCTYPE html>
<html>

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=9; IE=8; IE=7; IE=EDGE">
    <meta http-equiv="X-UA-Compatible" content="IE=EmulateIE7" />
    <title>设置-个人信息</title>
     <link rel="icon" href="./img/favicon.ico">

	<script src="./js/plugins/jquery/jquery.min.js"></script>
	<script src="js/plugins/vue.js"></script>
	<script src="js/plugins/axios.js"></script>
	<link rel="stylesheet" href="./js/plugins/elementui/index.css">
    <link rel="stylesheet" type="text/css" href="./css/all.css" />
    <link rel="stylesheet" type="text/css" href="./css/pages-seckillOrder.css" />
	<script src="./js/plugins/elementui/index.js"></script>
	<script src="./js/plugins/healthmobile.js"></script>
</head>

<body>
    <!-- 头部栏位 -->
    <!--页面顶部-->
<div id="app">
<div id="nav-bottom">
	<!--顶部-->
	<div class="nav-top">
		<div class="top">
			<div class="py-container">
				<div class="shortcut">
					<ul class="fl">
						<li class="f-item">青橙欢迎您！</li>
						<li class="f-item">请<a href="login.html" target="_blank">登录</a>　<span><a href="register.html" target="_blank">免费注册</a></span></li>
					</ul>
					<div class="fr typelist">
						<ul class="types">
							<li class="f-item"><span>我的订单</span></li>
							
							<li class="f-item"><span><a href="cart.html" target="_blank">我的购物车</a></span></li>
							<li class="f-item"><span><a href="home.html" target="_blank">我的青橙</a></span></li>			
							<li class="f-item"><span>青橙会员</span></li>						
							<li class="f-item"><span>企业采购</span></li>						
							<li class="f-item"><span>关注青橙</span></li>
							<li class="f-item"><span><a href="cooperation.html" target="_blank">合作招商</a></span></li>
							<li class="f-item"><span><a href="shoplogin.html" target="_blank">商家后台</a></span></li>				
							<li class="f-item"><span>网站导航</li>
						</ul>
					</div>
					
				</div>
			</div>
		</div>

		<!--头部-->
		<div class="header">
			<div class="py-container">
				<div class="yui3-g Logo">
					<div class="yui3-u Left logoArea">
						<a class="logo-bd" title="青橙" href="index.html" target="_blank"></a>
					</div>
					<div class="yui3-u Rit searchArea">
						<div class="search">
							<form action="" class="sui-form form-inline">
								<!--searchAutoComplete-->
								<div class="input-append">
									<input type="text" id="autocomplete" class="input-error input-xxlarge" />
									<button class="sui-btn btn-xlarge btn-danger" type="button">搜索</button>
								</div>
							</form>
						</div>
					</div>
					
				</div>

			</div>
		</div>
	</div>
</div>

    <!--header-->
    <div id="account">
        <div class="py-container">
            <div class="yui3-g home">
                <!--左侧列表-->
                <div class="yui3-u-1-6 list">

                    <div class="person-info">
                        <div class="person-photo"><img src="./img/_/photo.png" alt=""></div>
                        <div class="person-account">
							<span class="name">{{loginName}}</span>
							<span class="safe"><a href="/logout">退出登录</a></span>
                        </div>
                        <div class="clearfix"></div>
                    </div>
                    <div class="list-items">
                        <dl>
							<dt><i>·</i> 订单中心</dt>
							<dd ><a href="center-index.html" >我的订单</a></dd>
							<dd><a href="center-order-pay.html" >待付款</a></dd>
							<dd><a href="center-order-send.html"  >待发货</a></dd>
							<dd><a href="center-order-receive.html" >待收货</a></dd>
							<dd><a href="center-order-evaluate.html"  >待评价</a></dd>
						</dl>
						<dl>
							<dt><i>·</i> 我的中心</dt>
							<dd><a href="center-collect.html">我的收藏</a></dd>
							<dd><a href="center-footmark.html" >我的足迹</a></dd>
						</dl>
						<dl>
							<dt><i>·</i> 物流消息</dt>
						</dl>
						<dl>
							<dt><i>·</i> 设置</dt>
							<dd><a href="center-setting-info.html"  >个人信息</a></dd>
							<dd><a href="center-setting-address.html" >地址管理</a></dd>
							<dd><a href="center-setting-safe.html" class="list-active">安全管理</a></dd>
						</dl>
                    </div>
                </div>
                <!--右侧主内容-->
                <div class="yui3-u-5-6">
                    <div class="body userSafe">
                        <ul class="sui-nav nav-tabs nav-large nav-primary ">
                            <li class="active" @click="selectTab('one')" id="oneTab"><a href="javascript:void(0);"
												   data-toggle="tab">密码设置</a></li>
                            <li @click="selectTab('two')" id="twoTab"><a href="javascript:void(0);"
									data-toggle="tab">绑定手机</a></li>
                        </ul>
                        <div class="tab-content ">
                            <div id="one" class="tab-pane active">
                                <form class="sui-form form-horizontal sui-validate" id="jsForm">
                                    <div class="control-group">
                                        <label for="inputusername"
											   class="control-label">旧密码：
										</label>
                                        <div class="controls">
                                            <input id="pwdid"
												   v-model="passWordFormData.oldPassword"
												   class="fn-tinput"
												   data-rule-remote="http://www.baidu.com" type="password" name="OldPassword" placeholder="输入旧密码"
                                                required
												   data-msg-required="请输入旧密码"
												   minlength="6" data-msg-minlength="至少输入6个字符"
                                            />

                                        </div>
                                    </div>
                                    <div class="control-group">
                                        <label for="inputPassword"
											   class="control-label">新密码：</label>
                                        <div class="controls">
                                            <input class="fn-tinput"
												   v-model="passWordFormData.password" type="password" name="password" value="" placeholder="新密码" required id="password" data-rule-remote="php.php">
                                        </div>
                                    </div>
                                    <div class="control-group">
                                        <label for="inputRepassword"
											   class="control-label">重复新密码：</label>
                                        <div class="controls">
                                            <input class="fn-tinput"
												   v-model="passWordFormData.confirmPassword" type="password" name="confirm_password" value="" placeholder="确认新密码" required equalTo="#password">
                                        </div>
                                    </div>

                                    <div class="control-group">
                                        <label class="control-label"></label>
                                        <div class="controls">
                                            <button type="button"
													class="sui-btn btn-primary" @click="handleEdit()">提交</button>
                                        </div>
                                    </div>
                                </form>
                            </div>
                            <div id="two" class="tab-pane">
                                <!--步骤条-->
                                <div class="sui-steps steps-auto">
                                    <div class="wrap">
                                        <div class="finished">
                                        <label><span class="round"><i class="sui-icon icon-pc-right"></i></span><span>第一步 验证身份</span></label><i class="triangle-right-bg"></i><i class="triangle-right"></i>
                                        </div>
                                    </div>
                                    <div class="wrap">
                                        <div class="todo">
                                        <label><span class="round">2</span><span>第二步 绑定新手机号</span></label><i class="triangle-right-bg"></i><i class="triangle-right"></i>
                                        </div>
                                    </div>
                                    <div class="wrap">
                                        <div class="todo">
                                        <label><span class="round">3</span><span>第三步 完成</span></label>
                                        </div>
                                    </div>
                                </div>

                                <!--表单-->

                                <form class="sui-form form-horizontal sui-validate" data-toggle='validate' id="bind-form">

                                    <div class="control-group">
                                        <label for="inputPassword" class="control-label">验证方式：</label>
                                        <div class="controls fixed">手机验证（{{mobilePhone}}）
										</div>
                                    </div>
                                     <div class="control-group">
                                        <label for="inputcode" class="control-label">验证码：</label>
                                        <div class="controls">
                                            <input name="inputcode"
												   type="text" id="inputcode"
												   v-model="mobileFromData.verifyCode">
                                        </div>
                                        <div class="controls">
											<a href="#"
											   @click="changeVimg()"><img
													id="shaodi" src="/verifyCode/vImg" alt="验证码"></a>
                                        </div>
                                    </div>
                                    <div class="control-group">
                                        <label for="inputRepassword" class="control-label">短信验证码：</label>
                                        <div class="controls">
                                            <input name="msgcode" type="text"
												   id="msgcode"
												   v-model="mobileFromData.smsCode">
                                        </div>
                                        <div class="controls">
                                            <a id="validateCodeButton"
											   class="sui-btn btn-info"
													@click="sendSms()"
											>发送</a>
                                        </div>
                                    </div>
                                    <div class="control-group next-btn">
                                        <a class="sui-btn btn-primary"
										   @click="checkAllCode()">下一步</a>
                                    </div>
                                </form>
                            </div>
                        </div>

                    </div>
                </div>
            </div>
        </div>
    </div>
    <!-- 底部栏位 -->
    <!--页面底部-->
<div class="clearfix footer">
	<div class="py-container">
		<div class="footlink">
			<div class="Mod-service">
				<ul class="Mod-Service-list">
					<li class="grid-service-item intro  intro1">

						<i class="serivce-item fl"></i>
						<div class="service-text">
							<h4>正品保障</h4>
							<p>正品保障，提供发票</p>
						</div>

					</li>
					<li class="grid-service-item  intro intro2">

						<i class="serivce-item fl"></i>
						<div class="service-text">
							<h4>正品保障</h4>
							<p>正品保障，提供发票</p>
						</div>

					</li>
					<li class="grid-service-item intro  intro3">

						<i class="serivce-item fl"></i>
						<div class="service-text">
							<h4>正品保障</h4>
							<p>正品保障，提供发票</p>
						</div>

					</li>
					<li class="grid-service-item  intro intro4">

						<i class="serivce-item fl"></i>
						<div class="service-text">
							<h4>正品保障</h4>
							<p>正品保障，提供发票</p>
						</div>

					</li>
					<li class="grid-service-item intro intro5">

						<i class="serivce-item fl"></i>
						<div class="service-text">
							<h4>正品保障</h4>
							<p>正品保障，提供发票</p>
						</div>

					</li>
				</ul>
			</div>
			<div class="clearfix Mod-list">
				<div class="yui3-g">
					<div class="yui3-u-1-6">
						<h4>购物指南</h4>
						<ul class="unstyled">
							<li>购物流程</li>
							<li>会员介绍</li>
							<li>生活旅行/团购</li>
							<li>常见问题</li>
							<li>购物指南</li>
						</ul>

					</div>
					<div class="yui3-u-1-6">
						<h4>配送方式</h4>
						<ul class="unstyled">
							<li>上门自提</li>
							<li>211限时达</li>
							<li>配送服务查询</li>
							<li>配送费收取标准</li>
							<li>海外配送</li>
						</ul>
					</div>
					<div class="yui3-u-1-6">
						<h4>支付方式</h4>
						<ul class="unstyled">
							<li>货到付款</li>
							<li>在线支付</li>
							<li>分期付款</li>
							<li>邮局汇款</li>
							<li>公司转账</li>
						</ul>
					</div>
					<div class="yui3-u-1-6">
						<h4>售后服务</h4>
						<ul class="unstyled">
							<li>售后政策</li>
							<li>价格保护</li>
							<li>退款说明</li>
							<li>返修/退换货</li>
							<li>取消订单</li>
						</ul>
					</div>
					<div class="yui3-u-1-6">
						<h4>特色服务</h4>
						<ul class="unstyled">
							<li>夺宝岛</li>
							<li>DIY装机</li>
							<li>延保服务</li>
							<li>品优购E卡</li>
							<li>品优购通信</li>
						</ul>
					</div>
					<div class="yui3-u-1-6">
						<h4>帮助中心</h4>
						<img src="./img/wx_cz.jpg">
					</div>
				</div>
			</div>
			<div class="Mod-copyright">
				<ul class="helpLink">
					<li>关于我们<span class="space"></span></li>
					<li>联系我们<span class="space"></span></li>
					<li>关于我们<span class="space"></span></li>
					<li>商家入驻<span class="space"></span></li>
					<li>营销中心<span class="space"></span></li>
					<li>友情链接<span class="space"></span></li>
					<li>关于我们<span class="space"></span></li>
					<li>营销中心<span class="space"></span></li>
					<li>友情链接<span class="space"></span></li>
					<li>关于我们</li>
				</ul>
				<p>地址：北京市昌平区建材城西路金燕龙办公楼一层 邮编：100096 电话：400-618-4000 传真：010-82935100</p>
				<p>京ICP备08001421号京公网安备110108007702</p>
			</div>
		</div>
	</div>
</div>
</div>
	<!--页面底部END-->
	<script>
		var vueOrder = new Vue({
			el: "#app",
			data:{
				loginName:"",
				smsIsSend: false,
				passWordFormData:{},
				mobilePhone: "",
                mobileFromData:{},
			},
			mounted(){
				axios.get(`/user/loginName`).then( response=>{
					this.loginName= response.data.message;
				});
				axios.get("/user/mobilePhone").then( response=>{
					vueOrder.mobilePhone = response.data.message;
				});
			},
			methods:{
				checkAllCode(){
					if(vueOrder.mobileFromData.verifyCode == null ||
							vueOrder.mobileFromData.smsCode == null){
						this.$message.error("请输入验证码");
						return;
					}
					axios.post("/setting/safe/mobile/first",vueOrder.mobileFromData).then( (response) => {
					    if(response.data.flag == false){
							this.$message.error(response.data.message);
						}else if(response.data.flag == true){
					    	this.$message.success("验证码校验成功")
					        location.href="center-setting-safe-phone.html";
						};
					})
				},
				changeVimg(){
					var eid = document.getElementById("shaodi");
					eid.src="/verifyCode/vImg?"+new Date().getTime();
				},
				sendSms(){
				    if(vueOrder.smsIsSend){
				    	return;
					}
					if(vueOrder.mobileFromData.verifyCode == null){
						this.$message.error("请输入验证码");
						return;
					};
				    axios.post("/setting/safe/mobile/sendsms",vueOrder.mobileFromData).then( (response) =>{
						if(response.data.flag == false){
							this.$message.error(response.data.message);
						}else if(response.data.flag == true){
							this.$message.success("短信发送成功");
							validateCodeButton = $("#validateCodeButton");
							clock = window.setInterval(doLoop, 1000); //一秒执行一次
							vueOrder.smsIsSend = true;
						}
					})
				},
				selectTab(tabName){
					if(tabName.toString()=="one"){
						$("#two").removeClass().addClass("tab-pane");
						$("#twoTab").removeClass();
						$("#one").removeClass().addClass("tab-pane").addClass("active");
						$("#oneTab").removeClass().addClass("active");
					}else if(tabName.toString()=="two"){
						$("#one").removeClass().addClass("tab-pane");
						$("#oneTab").removeClass();
						$("#two").removeClass().addClass("tab-pane").addClass("active");
						$("#twoTab").removeClass().addClass("active");
					}
				},
				handleEdit(){
				    if(vueOrder.passWordFormData.oldPassword==null
					|| vueOrder.passWordFormData.password==null
					|| vueOrder.passWordFormData.confirmPassword==null){
						this.$message.error("不能为空");
				        return;
					}
				    if(vueOrder.passWordFormData.password !=
							vueOrder.passWordFormData.confirmPassword){
						this.$message.error("新密码两次输入不一致");
				    	return;
					}
					axios.post("/setting/safe/pwd",vueOrder.passWordFormData).then((res)=> {
						//将检查项列表数据赋值给模型数据用于页面表格展示
						console.log(res);
						if(res.data.flag == false){
							this.$message.error(res.data.message);
						}else if(res.data.flag == true){
							this.$alert('密码修改成功，请重新登陆', 'success', {
								confirmButtonText: '确定',
								callback: action => {
									this.$message({
										type: 'info',
										message: "请重新登陆"
									});
									location.href="/logout";
								}
							});
						}
					}).catch((err)=>{
						this.$message.error(err);
					});
				}
			}
		});
	</script>




</body>

</html>